home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Arashi 1.1 / Game Source / mtz / mtz src / loadsave.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-01  |  1.7 KB  |  66 lines  |  [TEXT/KAHL]

  1. #include <VA.h>
  2. #include "STORM.h"
  3. #include "GamePause.h"
  4. #include "PlayOptions.h"
  5.  
  6. extern    Player            Hero;        /* mz */
  7. extern    int                ScoretoBeatIndex;    /* mz */
  8.  
  9. typedef struct{
  10.         int        lvnum;
  11.         int        Doomsday;
  12.         long    score;
  13.         int        lives;
  14.         long    freelives;
  15.         int        RestartMode;
  16.         int        Flags;
  17.         int        NumZaps;
  18.         } **GameRecHand, GameRec;
  19.         
  20. void SaveGameF()
  21. {
  22.     GameRecHand    TheGameHand;
  23.     GameRec        TheGame;
  24.                                 
  25.     TheGameHand = GetResource('SVGM',128 +  PlayOptions ->restart);
  26.     (**TheGameHand).lvnum = ThisLevel.lvNumber; 
  27.     (**TheGameHand).Doomsday = ThisLevel.Doomsday;
  28.     (**TheGameHand).lives = Hero.lives;
  29.     (**TheGameHand).score = Hero.score;
  30.     (**TheGameHand).freelives = Hero.freeLives;
  31.     (**TheGameHand).RestartMode = PlayOptions ->restart;
  32.     (**TheGameHand).Flags = Hero.Flags;
  33.     (**TheGameHand).NumZaps = ThisLevel.plSuperZaps;
  34.     ChangedResource(TheGameHand);
  35.     WriteResource(TheGameHand);
  36.     ReleaseResource(TheGameHand);
  37.     if(PlayOptions ->restart)
  38.         ParamText("\pPractice",nil,nil,nil);
  39.     else
  40.         ParamText("\pArcade",nil,nil,nil);
  41.     Alert(500,0); 
  42. }
  43.  
  44. void LoadGameF()
  45. {    GameRecHand    TheGameHand;
  46.     GameRec    TheGame;
  47.                                 
  48.     TheGameHand = GetResource('SVGM',128 +  PlayOptions->restart);
  49.                                 
  50.     PlayOptions ->restart = (**TheGameHand).RestartMode;
  51.                             
  52.     ThisLevel.lvNext = (**TheGameHand).lvnum;
  53.     ThisLevel.Doomsday = (**TheGameHand).Doomsday;
  54.  
  55.     STLoadLevel();    
  56.  
  57.     /* if a Doomsday level dont reset # of zaps */
  58.     if(ThisLevel.Doomsday)
  59.         ThisLevel.plSuperZaps = (**TheGameHand).NumZaps;
  60.     Hero.lives = (**TheGameHand).lives;            
  61.     Hero.score = (**TheGameHand).score;            
  62.     Hero.drawscore = 1;        
  63.     Hero.freeLives = (**TheGameHand).freelives;            
  64.     Hero.Flags = (**TheGameHand).Flags;
  65.     ReleaseResource(TheGameHand);
  66. }